#include "CollisionStates.h"
#include "Collision.h"
#include "Message Dispatcher.h"
#include "Entity Manager.h"
#include "Character.h"
#include "Steering Behavior.h"

// Will check if the direction CharacterOne is going will make it collide with CharacterTwo
bool WillIntersect(Character* CharacterOne, Character* CharacterTwo)
{
	return true;
}
// Unresolved
void Unresolved::Enter(Collision* collision)
{
	;
}

void Unresolved::Execute(Collision* collision)
{
	switch(collision->Case())
	{
	case Case1:
		{
			// Do nothing, and set the collision state to resolving
			collision->m_CollisionState.ChangeState(Resolving::Instance());
			break;
		}
	case Case2:
		{
			
			collision->m_CollisionState.ChangeState(Resolving::Instance());
			break;
		}

	case Case3:
		{
			collision->m_CollisionState.ChangeState(Resolving::Instance());
			break;
		}

	case Case4:
		{
			collision->m_CollisionState.ChangeState(Resolving::Instance());
		}

	}
}

void Unresolved::Exit(Collision* collision)
{
	;
}

// Resolving
void Resolving::Enter(Collision* collision)
{
	if(collision->m_Case == Case1)
	{
		collision->m_pOwner->EvadeCharacter(collision->m_pCollidingCharacter);
	}

}

void Resolving::Execute(Collision* collision)
{
	if(collision->m_pCollidingCharacter != NULL)
	{
		if(!EntityMgr->CheckCollision(collision->m_pOwner->ID(), collision->m_pCollidingCharacter->ID()))
		{
			collision->m_CollisionState.ChangeState(Resolved::Instance());
		}
	}

	if(collision->m_pCollidingBuilding != NULL )
	{
		if(collision->m_pOwner->GetPath() == NULL)
			collision->m_CollisionState.ChangeState(Resolved::Instance());
	}

	
}
void Resolving::Exit(Collision* collision)
{
	if(collision->m_Case == Case1)
	{
		collision->m_pOwner->StopEvadingCharacter();
		collision->m_pOwner->Stop();
	}
}

// Resolved
void Resolved::Enter(Collision* collision)
{
	collision->resolved = true;
}

void Resolved::Execute(Collision* collision)
{
	;
}

void Resolved::Exit(Collision* collision)
{
	;
}